/**
 * jims
 */
package com.jims.master.modules.physical.service;

import com.jims.master.common.persistence.Page;
import com.jims.master.common.service.CrudService;
import com.jims.master.modules.physical.dao.TResultGroupDao;
import com.jims.master.modules.physical.dao.TResultGroupListDao;
import com.jims.master.modules.physical.entity.TResultGroup;
import com.jims.master.modules.physical.entity.TResultGroupList;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.*;

/**
 * Service
 * @author zp
 * @version 2017-06-21
 */
@Service
@Transactional(readOnly = true)
public class TResultGroupService extends CrudService<TResultGroupDao, TResultGroup> {

	@Autowired
	private TResultGroupListDao tResultGroupListDao;

	public TResultGroup get(String id) {
		return super.get(id);
	}
	
	public List<TResultGroup> findList(TResultGroup tResultGroup) {
		return super.findList(tResultGroup);
	}
	
	public Page<TResultGroup> findPage(Page<TResultGroup> page, TResultGroup tResultGroup) {
		return super.findPage(page, tResultGroup);
	}
	
	@Transactional(readOnly = false)
	public int save(TResultGroup tResultGroup) {
		return super.save(tResultGroup);
	}
	
	@Transactional(readOnly = false)
	public int delete(TResultGroup tResultGroup) {
		return super.delete(tResultGroup);
	}


	@Transactional(readOnly = false)
	public List<TResultGroupList> itemList(String clinicId,String deptId,String orgId){
		List<TResultGroupList> lists = new ArrayList<TResultGroupList>();
		String uuids = UUID.randomUUID().toString();
		Map<String,Object> map = new HashMap<String,Object>();
		map.put("clinicId",clinicId);
		map.put("deptId",deptId);
		map.put("orgId", orgId);
		map.put("uuids", uuids);
		map.put("result", "0");
		String i = dao.itemList(map);
			lists = tResultGroupListDao.findList(new TResultGroupList(uuids));
			tResultGroupListDao.delete(new TResultGroupList(uuids));
		return lists;
	}

}